package com.micro.service.entity;

/**
 * Create by Vic Xu on 2019/3/12
 */
public class ResponseMessage<T> {

    private T data;

    private Integer code;

    private String msg;

    private String exceptionMsg;

    public static <T> ResponseMessage<T> success(T data) {
        return new ResponseMessage<>(data);
    }

    public static <T> ResponseMessage<T> error(Integer code, String msg) {
        return new ResponseMessage<>(code, msg);
    }

    public static <T> ResponseMessage<T> exception(Integer code, String msg, String exceptionMsg) {
        return new ResponseMessage<>(code, msg, exceptionMsg);
    }

    public static <T> ResponseMessage<T> fallback(Integer code, String msg) {
        return new ResponseMessage<>(code, msg);
    }


    public ResponseMessage(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseMessage(T data) {
        this.data = data;
        this.code = 200;
        this.msg = "SUCCESS";
    }

    public ResponseMessage(Integer code, String msg, String exceptionMsg) {
        this.code = code;
        this.msg = msg;
        this.exceptionMsg = exceptionMsg;
    }

    public T getData() {
        return data;
    }

    public ResponseMessage() {
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getExceptionMsg() {
        return exceptionMsg;
    }

    public void setExceptionMsg(String exceptionMsg) {
        this.exceptionMsg = exceptionMsg;
    }
}
